/**
 * Copyright (C) 2021-2022 maminjie <canpool@163.com>
 * SPDX-License-Identifier: LGPL-2.1
 * Powered by Qt-Advanced-Docking-System
**/

#pragma once

#include "qads_global.h"

#include <QWidget>
#include <QToolButton>

QADS_BEGIN_NAMESPACE

/**
 * Title bar button of a dock pannel that customizes TitleBarButtonType appearance/behavior
 * according to various config flags such as:
 * QAds::TitleBarHas_xxx_Button - if set to 'false' keeps the button always invisible
 * QAds::TitleBarHideDisabledButtons - if set to 'true' hides button when it is disabled
 */
class DockTitleBarButton : public QToolButton
{
    Q_OBJECT
public:
    DockTitleBarButton(bool visible = true, QWidget *parent = nullptr);

    void setVisible(bool visible) override;

protected:
    bool event(QEvent *event) override;

private:
    bool m_visible = true;
    bool m_hideWhenDisabled = false;
};

/**
 * This spacer widget is here because of the following problem.
 * The dock pannel title bar handles mouse dragging and moving the floating widget.
 * The problem is that if the title bar becomes invisible, i.e. if the dock
 * pannel contains only one single dock widget and the dock pannel is moved
 * into a floating widget, then mouse events are not handled anymore and dragging
 * of the floating widget stops.
 */
class DockTitleBarSpacer : public QWidget
{
public:
    DockTitleBarSpacer(QWidget *parent = nullptr);

    QSize sizeHint() const override { return QSize(0, 0); }
    QSize minimumSizeHint() const override { return QSize(0, 0); }
};

QADS_END_NAMESPACE
